<?php
/**
 * @package YARBB
 * @copyright Авторские права (C) 2009 www.yar-it.com. Все права защищены.
 * @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
 * YARBB! - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
 * Для получения информации о используемых расширениях и замечаний об авторском праве, смотрите файл copyright.php.
 */
// don't allow direct linking
defined('_VALID_MOS') or die();

//require $yarbb_path . '/plugins/bbcode.php';

$action = strval(mosGetParam($_GET, 'action', null));
$id	 	= intval(mosGetParam($_GET, 'id', 0));
$pid	= intval(mosGetParam($_GET, 'pid', 0));
$page   = intval(mosGetParam($_GET, 'page', 1));

if ($id < 1 && $pid < 1) {
	mosRedirect(sefRelToAbs(YARBB_URL), _Y_404);
}

// прямой переход к конкретному сообщению
if ($pid) {
	$sql = 'SELECT topic_id FROM #__forum_posts WHERE id=' . $pid;
	$database->setQuery($sql);
	$id = $database->loadResult();
	if (!$id) { // тема не найдена
		mosRedirect(sefRelToAbs(YARBB_URL), _Y_404);
	}
// если пользователь не гость, и хочет посомтреть новое сообщение
} elseif ($action == 'new' && !$yarbb_user['is_guest']) {
	$sql = ('SELECT MIN(id) FROM #__forum_posts WHERE topic_id=' . $id . ' AND posted>' . $yarbb_user['last_visit']);
	$first_new_post_id = $database->setQuery($sql)->loadResult();
	if ($first_new_post_id) {
		mosRedirect(sefRelToAbs(YARBB_URL . '&amp;task=viewtopic&amp;pid=' . $first_new_post_id ). '#p' . $first_new_post_id);
	}else {
		mosRedirect(sefRelToAbs(YARBB_URL . '&amp;task=viewtopic&amp;id=' . $id . '&amp;action=last'));
	}
// переход к последнему сообщению в теме
} elseif ($action == 'last') {
	$sql = 'SELECT id FROM #__forum_posts WHERE topic_id=' . $id . ' ORDER BY id DESC LIMIT 1';
	//$database->setQuery($sql);
	$last_post_id = $database->setQuery($sql)->loadResult();
	if ($last_post_id) {
		mosRedirect(sefRelToAbs(YARBB_URL . '&amp;task=viewtopic&amp;pid=' . $last_post_id ). '#p' . $last_post_id);
	}
}
// Fetch some info about the topic
if (!$yarbb_user['is_guest']) {
	$sql = 'SELECT pf.forum_name AS parent_forum, f.parent_forum_id, t.subject, t.descrip_t, t.closed, t.num_replies, t.sticky, t.posted, t.yes, t.no, t.labels, f.id AS forum_id, f.forum_name, f.forum_key, f.moderators, fp.post_replies, s.user_id AS is_subscribed
	FROM #__forum_topics AS t
	INNER JOIN #__forum_forums AS f ON f.id=t.forum_id
	LEFT JOIN #__forum_subscriptions AS s ON (t.id=s.topic_id AND s.user_id=' . $yarbb_user['id'] . ')
	LEFT JOIN #__forum_forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=' . $yarbb_user['g_id'] . ')
	LEFT JOIN #__forum_forums AS pf ON f.parent_forum_id=pf.id
	WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=' . $id . ' AND t.moved_to IS NULL';
}else {
	$sql = 'SELECT pf.forum_name AS parent_forum, f.parent_forum_id, t.subject, t.descrip_t, t.closed, t.num_replies, t.sticky, t.posted, t.yes, t.no, t.labels, f.id AS forum_id, f.forum_name, f.forum_key, f.moderators, fp.post_replies, 0
	FROM #__forum_topics AS t
	INNER JOIN #__forum_forums AS f ON f.id=t.forum_id
	LEFT JOIN #__forum_forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=' . $yarbb_user['g_id'] . ')
	LEFT JOIN #__forum_forums AS pf ON f.parent_forum_id=pf.id
	WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id=' . $id . ' AND t.moved_to IS NULL';
}

$cur_topic = $database->setQuery($sql)->loadAssocRow();

// тема не существует
if (!$cur_topic) {
	mosRedirect(sefRelToAbs(YARBB_URL), _Y_404);
}

// получаем для форума модераторов и админов
$mods_array = ($cur_topic['moderators'] != '') ? unserialize($cur_topic['moderators']) : array();
$is_admmod  = ($yarbb_user['g_id'] == YARBB_ADMIN || ($yarbb_user['g_id'] == YARBB_MOD && array_key_exists($yarbb_user['username'], $mods_array)) || $yarbb_user['g_global_moderation']) ? true : false;

// постраничка
$num_pages		= ceil(($cur_topic['num_replies'] + 1) / $yarbb_user['disp_posts']);
$page			= ($page > $num_pages) ? 1 : $page;
$start_from		= $yarbb_user['disp_posts'] * ($page - 1);
$paging_links	= _PN_PAGE . ': ' . paginate($num_pages, $page, YARBB_URL . '&amp;task=viewtopic&amp;id=' . $id );

// загрузка списка пользователй для игнорирования
if ($yarbb_user['ignore_mode']) {
	$ignored_users = explode(",", $yarbb_user['ignored_users']);
}

// цензура-фильрация темы
if ($yarbb_config['o_censoring'] == '1') {
	$cur_topic['subject'] = censor_words($cur_topic['subject']);
}

// возможность быстрого ответа
$quickpost = false;
if ($yarbb_config['o_quickpost'] == '1' && !$yarbb_user['is_guest'] && ($cur_topic['post_replies'] == '1' || ($cur_topic['post_replies'] == '' && $yarbb_user['g_post_replies'] == '1')) && ($cur_topic['closed'] == '0' || $is_admmod)) {
	$required_fields = array(
			'req_message' => _Y_YARMESS4
	);
	$quickpost	   = true;
}

// установка мета-тэгов
$mainframe->setPageTitle(yarbb_htmlspecialchars($cur_topic['subject']));
$mainframe->appendMetaTag('keywords', yarbb_htmlspecialchars($cur_topic['forum_key']));
$mainframe->appendMetaTag('description', yarbb_htmlspecialchars($cur_topic['descrip_t']));

require_once $yarbb_path . '/plugins/nbbc_custom.php';

// навигация по форумам и подфорумакм
$current_path = $cur_topic['parent_forum'] ? "\t\t".'&nbsp;<ul><li><a href="' . sefRelToAbs(YARBB_URL) . '">' . _Y_INDEX . '</a>&nbsp;</li><li>&raquo;&nbsp;<a href="' . sefRelToAbs(YARBB_URL . '&amp;task=viewforum&amp;id=' . $cur_topic['parent_forum_id']) . '">' . yarbb_htmlspecialchars($cur_topic['parent_forum']) . '</a>&nbsp;</li><li>&raquo;&nbsp;<a href="' . sefRelToAbs(YARBB_URL . '&amp;task=viewforum&amp;id=' . $cur_topic['forum_id']) . '">' . yarbb_htmlspecialchars($cur_topic['forum_name']) . '</a>&nbsp;</li><li>&raquo;&nbsp;' . yarbb_htmlspecialchars($cur_topic['subject']) . '</li></ul>' : "\t\t" . '<ul><li><a href="' . sefRelToAbs(YARBB_URL) . '">' . _Y_INDEX . '</a></li><li>&nbsp;&raquo;&nbsp;<a href="' . sefRelToAbs(YARBB_URL . '&amp;task=viewforum&amp;id=' . $cur_topic['forum_id']) . '">' . yarbb_htmlspecialchars($cur_topic['forum_name']) . '</a></li><li>&nbsp;&raquo;&nbsp;' . yarbb_htmlspecialchars($cur_topic['subject']) . '</li></ul>'

?>

<div class="linkst">
	<div class="inbox">
		<p class="pagelink conl">
<?php
			echo $paging_links;
			?>
		</p>
<?php/*
		if ($cur_topic['parent_forum']) {
			echo "\t\t" . '&nbsp;<ul><li><a href="' . sefRelToAbs(YARBB_URL) . '">' . _Y_INDEX . '</a>&nbsp;</li><li>&raquo;&nbsp;<a href="' . sefRelToAbs(YARBB_URL . '&amp;task=viewforum&amp;id=' . $cur_topic['parent_forum_id']) . '">' . yarbb_htmlspecialchars($cur_topic['parent_forum']) . '</a>&nbsp;</li><li>&raquo;&nbsp;<a href="' . sefRelToAbs(YARBB_URL . '&amp;task=viewforum&amp;id=' . $cur_topic['forum_id']) . '">' . yarbb_htmlspecialchars($cur_topic['forum_name']) . '</a>&nbsp;</li><li>&raquo;&nbsp;' . yarbb_htmlspecialchars($cur_topic['subject']) . '</li></ul>';
		}
		else {
			echo "\t\t" . '<ul><li><a href="' . sefRelToAbs(YARBB_URL) . '">' . _Y_INDEX . '</a></li><li>&nbsp;&raquo;&nbsp;<a href="' . sefRelToAbs(YARBB_URL . '&amp;task=viewforum&amp;id=' . $cur_topic['forum_id']) . '">' . yarbb_htmlspecialchars($cur_topic['forum_name']) . '</a></li><li>&nbsp;&raquo;&nbsp;' . yarbb_htmlspecialchars($cur_topic['subject']) . '</li></ul>';
		}*/
		?>
		<?php echo $current_path; ?>

		<div class="clearer"></div>
	</div>
</div>

<?php

$bg_switch  = true;
$post_count = 0;

$sql = 'SELECT COUNT(id) FROM #__forum_posts WHERE topic_id=' . $id;
$num_posts = $database->setQuery($sql)->loadResult();

$sql = 'SELECT u.id AS uid, ucore.avatar,u.use_avatar, u.email_setting, u.num_posts, u.admin_note, u.imgaward, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, p.userimage, g.g_id, g.g_user_title, g.g_color, o.userid AS is_online
			FROM #__forum_posts AS p
			INNER JOIN #__forum_users AS u ON u.id=p.poster_id
			INNER JOIN #__users AS ucore ON ucore.id=p.poster_id
			INNER JOIN #__forum_groups AS g ON g.g_id=u.group_id
			LEFT JOIN #__session AS o ON (o.userid=u.id AND o.guest=0)			
			WHERE p.topic_id=' . $id . '
			ORDER BY p.id ' . ($yarbb_user['reverse_posts'] ? 'DESC ' : '') . 'LIMIT ' . $start_from . ',' . $yarbb_user['disp_posts'];
$all_posts = $database->setQuery($sql)->loadAssocList();



foreach ($all_posts as $cur_post) {
	$post_count++;
	$user_avatar	  = '';
	$user_info		= array();
	$user_contacts	= array();
	$post_actions	 = array();
	$is_online		= '';
	$rank_pips		= '';
	// дял зарегистрированных пользователй делаем разные операции по рассчеты понтов и аватаров
	if ($cur_post['poster_id'] > 1) {
		// звёздочки крутизны автора сообщения
		if ($cur_post['num_posts'] > 1000) {
			$num_pips = 6;
		}elseif ($cur_post['num_posts'] > 500) {
			$num_pips = 5;
		}elseif ($cur_post['num_posts'] > 200) {
			$num_pips = 4;
		}elseif ($cur_post['num_posts'] > 100) {
			$num_pips = 3;
		}elseif ($cur_post['num_posts'] > 20) {
			$num_pips = 2;
		}else {
			$num_pips = 1;
		}
		// собираем звёздочки
		for ($pip = 0; $pip < $num_pips; $pip++) {
			$rank_pips .= '<img src="' . $yarbb_live . '/images/ranks/star.png" alt="" />';
		}

		$username = '<a href="' . sefRelToAbs('index.php?option=com_users&task=profile&amp;user=' . $cur_post['poster_id']). '"><span style="color:' . $cur_post['g_color'] . '">' . yarbb_htmlspecialchars($cur_post['username']) . '</span></a>';

		$user_title = get_title($cur_post);
		if ($yarbb_config['o_censoring'] == '1') {
			$user_title = censor_words($user_title);
		}

		// Format the online indicator
		$is_online = ($cur_post['is_online'] == $cur_post['poster_id']) ? '<strong><font color="green"><img src="' . $yarbb_live . '/theme/' . $yarbb_config['o_default_style'] . '/images/online.gif" title="' . _Y_YARONLINE . '" alt="' . _Y_YARONLINE . '" /></font></strong>' : '<font color="red"><img src="' . $yarbb_live . '/theme/' . $yarbb_config['o_default_style'] . '/images/offline.gif" title="' . _Y_YAROFFLINE . '" alt="' . _Y_YAROFFLINE . '" /></font>';

		if ($yarbb_config['o_avatars'] == '1' && $cur_post['use_avatar'] == '1' && $yarbb_user['show_avatars'] != '0') {
			$user_avatar = $yarbb_live.'/theme/'.$yarbb_config['o_default_style'].'/images/no_avatar.jpg';
		}

		$user = new mosUser($database);
		$user->avatar = $cur_post['avatar'];

		$cur_user_avatar =  JPATH_SITE.'/'.$user->get_avatar($user);
		$user_avatar = '<img src="'.$cur_user_avatar.'" alt="'.$user_title.'" width="100" />';
	}
	// lk
	else if ($cur_post['poster_id'] <= 1) {
		$username = '<span style="color:' . $cur_post['g_color'] . '">' . yarbb_htmlspecialchars($cur_post['username']) . '</span><br><small>Гость</small>';
		$user_avatar = '';
	}
	// lk /

	if (!$is_admmod) {
		if (!$yarbb_user['is_guest']) {
			$post_actions[] = '';
		}
		if ($cur_topic['closed'] == '0') {
			if ($cur_post['poster_id'] == $yarbb_user['id']) {
				if ((($start_from + $post_count) == 1 && $yarbb_user['g_delete_topics'] == '1') || (($start_from + $post_count) > 1 && $yarbb_user['g_delete_posts'] == '1')) {
					$post_actions[] = '<button onclick="document.location=\'' . sefRelToAbs(YARBB_URL . '&amp;task=delete&amp;id=' . $cur_post['id']) . '\';">' . _E_REMOVE . '</button>';
				}
				if ($yarbb_user['g_edit_posts'] == '1') {
					$post_actions[] = '<button onclick="document.location=\'' . sefRelToAbs(YARBB_URL . '&amp;task=edit&amp;id=' . $cur_post['id']) . '\';">' . _CHANGE . '</button>';
				}
			}
			if (($cur_topic['post_replies'] == '' && $yarbb_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1') {
				$post_actions[] = '<button onclick="document.location=\'' . sefRelToAbs(YARBB_URL . '&amp;task=post&amp;tid=' . $id . '&amp;qid=' . $cur_post['id']) . '\';">' . _Y_YARQUOTE . '</button>';
			}

			$post_actions[] = '<button onclick="document.location=\'' . sefRelToAbs(YARBB_URL . '&amp;task=post&amp;tid=' . $id) . '\';">' . _Y_YARPOSTREAPLY . '</button>';
		}
	}else {
		$post_actions[] = '
<button onclick="document.location=\'' . sefRelToAbs(YARBB_URL . '&amp;task=delete&amp;id=' . $cur_post['id']) . '\';">' . _E_REMOVE . '</button>
<button onclick="document.location=\'' . sefRelToAbs(YARBB_URL . '&amp;task=movepost&amp;id=' . $cur_post['id']) . '\';">' . _Y_YAR_MOVE . '</button>
<button onclick="document.location=\'' . sefRelToAbs(YARBB_URL . '&amp;task=edit&amp;id=' . $cur_post['id']) . '\';">' . _CHANGE . '</button>
<button onclick="document.location=\'' . sefRelToAbs(YARBB_URL . '&amp;task=post&amp;tid=' . $id . '&amp;qid=' . $cur_post['id']) . '\';">' . _Y_YARQUOTE . '</button>
<button onclick="document.location=\'' . sefRelToAbs(YARBB_URL . '&amp;task=post&amp;tid=' . $id) . '\';">' . _Y_YARPOSTREAPLY . '</button>';
	}

	// зебра
	$bg_switch = ($bg_switch) ? false : true;
	$vtbg	  = ($bg_switch) ? ' roweven' : ' rowodd';

	if ($yarbb_user['ignore_mode'] == '1' && in_array($cur_post['poster_id'], $ignored_users)) {
		$cur_post['message'] = "<i>" . _Y_YARIGNOR . "</i>";
	}else {
		$cur_post['message'] = $bbcode->Parse($cur_post['message'], $cur_post['hide_smilies']);
	}

	if (($start_from + $post_count) == 1) {
		$labels = (!empty($yarbb_config['o_topic_labels'])) ? $cur_topic['labels'] : '';
	}else {
		$labels = '';
	}

?>
	
<div id="p<?php echo $cur_post['id'];?>" class="blockpost<?php echo $vtbg;?><?php echo (($post_count + $start_from) == 1) ? ' firstpost' : '';?>">
	<h2>
		<span>
			<span class="conr">№<?php echo $yarbb_user['reverse_posts'] ? ($num_posts + 1 - ($start_from + $post_count)) : ($start_from + $post_count);?></span>
			<a href="<?php echo sefRelToAbs(YARBB_URL . '&amp;task=viewtopic&amp;pid=' . $cur_post['id'] ). '#p' . $cur_post['id'];?>"><?php echo format_time($cur_post['posted']);?></a>
		</span>
	</h2>
	<div class="box">
		<div class="userinfo">
			<table>
				<tr>
					<td rowspan="3" class="userimg">
						<div class="postleft">
							<dl>
								<dt class="usertitle"><?php echo $username;?></dt>
								<?php if ($cur_post['poster_id'] > 1) { ?>
								<dd class="postavatar"><a href="<?php echo sefRelToAbs('index.php?option=com_users&task=profile&amp;user=' . $cur_post['poster_id']) ?>" ><?php echo $user_avatar ?></a></dd>
								<dd class="usertitle"><?php echo $rank_pips;?></dd>
								<dd><?php echo ($cur_post['poster_id'] > 1) ? '<p>' . $is_online . '</p>' : '';?></dd>
								<?php } ?>
							</dl>
						</div>
					</td>
					<td class="spacer">
						<div class="postright" id="fulltext_<?php echo $cur_post['id'];?>"<?php echo ($yarbb_user['ignore_mode'] == '2' && in_array($cur_post['poster_id'], $ignored_users)) ? ' style="display: none;"' : '';?>>
							<h4><?php echo (($post_count + $start_from) > 1) ? ' Re: ' . yarbb_htmlspecialchars($cur_topic['subject']) : yarbb_htmlspecialchars($cur_topic['subject']); ?></h4>
							<div class="postmsg">
	<?php
	echo $cur_post['message'];

									// тэги сообщения
									if (!empty($labels)) {
										echo '<br><div class="topiclabels">' . _Y_TAGS . ': [' . show_labels($labels) . ']</div>';
									}

									if ($cur_post['edited'] != '') {
										echo "\t\t\t\t\t" . '<p class="postedit"><em>' . _Y_YARLASTEDIT . ' ' . yarbb_htmlspecialchars($cur_post['edited_by']) . ' (' . format_time($cur_post['edited']) . ')</em></p>' . "\n";
									}
									?>
							</div>
						</div>
					</td>
				</tr>
				<tr colspan="2">
					<td class="spacer">
						<div class="postfootright">
	<?php

	if ($yarbb_user['ignore_mode'] == '2' && in_array($cur_post['poster_id'], $ignored_users)) {
									echo '<div class="postright" id="ignoretext' . $cur_post['id'] . '"><i>' . _Y_YARIGNORED . '</i> [<a href="#" onclick="document.getElementById(\'fulltext' . $cur_post['id'] . '\').style.display=\'block\';document.getElementById(\'ignoretext' . $cur_post['id'] . '\').style.display=\'none\';return false;">' . _Y_YASHOWPOSTS . '</a>]</div>';
								}

								echo (count($post_actions)) ? '<div class="yarbuttomdiv">' . implode('', $post_actions) . '</div>' . "\n" : '</div>' . "\n";
								echo '</div>';

								if ($quickpost) {
									?><div class="yarpaste"><?php echo '<a onMouseOver="copyQ(\'' . $cur_post['username'] . '\');" href="javascript:pasteQ();" class="yarbuttom"><img src="' . $yarbb_live . '/theme/' . $yarbb_config['o_default_style'] . '/images/quote.gif" alt="' . _Y_YARPASTEQUOT . '" title="' . _Y_YARPASTEQUOT . '" /></a> <a onClick="javascript:pasteN(\'' . $cur_post['username'] . '\'); return false;" href="javascript:void(0)" class="yarbuttom"><img src="' . $yarbb_live . '/theme/' . $yarbb_config['o_default_style'] . '/images/user.gif" alt="' . _Y_YARPASTEUSR . '" title="' . _Y_YARPASTEUSR . '" /></a>';?></div><?php
								}

								?>

					</td>
				</tr>
			</table>
		</div>
	</div>
</div>
	<?php
	if ($post_count == '1' && $adsense_config['google_adsense_enabled'] == '1' && strpos($adsense_config['google_exclude_forums'], ',' . $cur_topic['forum_id'] . ',') === FALSE && strpos($adsense_config['google_exclude_groups'], ',' . $yarbb_user['g_id'] . ',') === FALSE) {
		?>
<div class="blockpost<?php echo $vtbg;?>">
	<div class="adsense">
		<div class="inbox">
		<?php if (mosCountModules("yarbb_ban")) { ?>
			<div id="user4"><?php mosLoadModules('yarbb_ban', -3);?></div>
			<?php }?>
			<div class="clearer"></div>
		</div>
	</div>
</div>
		<?php
	}
}
?>
<div class="postlinksb">
	<div class="inbox">
		<p class="pagelink conl"><?php echo $paging_links; ?></p>
		<p class="postlink conr"><?php echo $post_link;?></p>
		<p class="postlink conr">
<?php
if (!$yarbb_user['is_guest'] && $yarbb_config['o_subscriptions'] == '1') {
	if ($cur_topic['is_subscribed']) {
					$subscraction = '<p >' . _Y_YARUGESUBSKR . ' - <a href="' . sefRelToAbs(YARBB_URL . '&amp;task=misc&amp;unsubscribe=' . $id) . '">' . _Y_YAUNSUBSKR . '</a></p>' . "\n";
				}else {
					$subscraction = '<p><a href="' . sefRelToAbs(YARBB_URL . '&amp;task=misc&amp;subscribe=' . $id) . '">' . _Y_YAROPSUBS . '</a></p>' . "\n";
				}
			}else {
				$subscraction = '<div class="clearer"></div>'."\n";
			}

			
			define('YARBB_ALLOW_INDEX', 1);
			?>
		</p>
			<?php
			if ($cur_topic['parent_forum']) {
	echo "\t\t" . '<ul><li><a href="' . sefRelToAbs(YARBB_URL) . '">' . _Y_INDEX . '</a>&nbsp;</li><li>&raquo;&nbsp;<a href="' . sefRelToAbs(YARBB_URL . '&amp;task=viewforum&amp;id=' . $cur_topic['parent_forum_id']) . '">' . yarbb_htmlspecialchars($cur_topic['parent_forum']) . '</a>&nbsp;</li><li>&raquo;&nbsp;<a href="' . sefRelToAbs(YARBB_URL . '&amp;task=viewforum&amp;id=' . $cur_topic['forum_id']) . '">' . yarbb_htmlspecialchars($cur_topic['forum_name']) . '</a>&nbsp;</li><li>&raquo;&nbsp;' . yarbb_htmlspecialchars($cur_topic['subject']) . '</li></ul>';
		}else {
			echo "\t\t" . '<ul><li><a href="' . sefRelToAbs(YARBB_URL) . '">' . _Y_INDEX . '</a></li><li>&nbsp;&raquo;&nbsp;<a href="' . sefRelToAbs(YARBB_URL . '&amp;task=viewforum&amp;id=' . $cur_topic['forum_id']) . '">' . yarbb_htmlspecialchars($cur_topic['forum_name']) . '</a></li><li>&nbsp;&raquo;&nbsp;' . yarbb_htmlspecialchars($cur_topic['subject']) . '</li></ul>';
		}

		echo $subscraction;
		?>
	</div>
</div>
		<?php
$cur_index = 1;
// форма быстрого ответа
if ($quickpost) {
	?>
<div class="blockform">
	<h2><span><?php echo _Y_QUICK_POST;?></span></h2>
	<div class="box">
		<table>
			<tr>
				<td width="100">
			  <p class="use_rtitle"><?php echo $my->username ?></p>
	<?php
	$cur_user_avatar =  JPATH_SITE.'/'.$my->get_avatar($my);
	echo $user_avatar = '<img src="'.$cur_user_avatar.'" alt="'.$my->name.'" width="100" />';
						?>
				</td>
				<td>
					<form id="post" method="post" name="qpost" action="<?php echo sefRelToAbs(YARBB_URL . '&amp;task=post&amp;tid=' . $id);?>" onsubmit="this.submit.disabled=true;if(process_form(this)){return true;}else{this.submit.disabled=false;return false;}">
						<div class="inform">
							<div class="infldset txtarea">
								<input type="hidden" name="form_sent" value="1" />
								<input type="hidden" name="form_user" value="<?php echo (!$yarbb_user['is_guest']) ? yarbb_htmlspecialchars($yarbb_user['username']) : 'Guest';?>" />
								<textarea id="req_message" name="req_message" style="height: 100px; width: 98%" tabindex="<?php echo $cur_index++;?>" cols="" rows=""></textarea>
								<label><input type="checkbox" name="merge" value="1" checked="checked" /><?php echo _Y_YARMERGEADD;?></label>
							</div>
							<input type="submit" name="submit" value="<?php echo _SUBMIT_BUTTON;?>" tabindex="<?php echo $cur_index++;?>" accesskey="s" />
							<input name="" type="button" onclick="javascript:PopUp('<?php echo sefRelToAbs(YARBB_URL_ATTACH . '&amp;task=attach');?>', 'gest', '850', '530', 'resizable=yes, location=no, menubar=no, status=no, scrollbars=yes')" value="<?php echo _Y_YARATTACHFILE;?>" />
							<input type="submit" name="preview" value="<?php echo _PREVIEW; ?>" tabindex="<?php echo $cur_index++;?>" accesskey="p" />
							<input name="input" type="button" onclick="javascript:history.go(-1)" value="<?php echo _Y_MENU_BACK; ?>" />
					</form>
					</div>
				</td>
			</tr>
		</table>
	</div>
</div>
	<?php
}

// обновляем число просомтров темы
$database->setQuery( 'UPDATE LOW_PRIORITY #__forum_topics SET num_views=num_views+1 WHERE id='.$id )->query();
$forum_id = $cur_topic['forum_id'];
$footer_style = 'viewtopic';